package com.ruoyi.food.util;

import java.util.UUID;

import org.springframework.web.multipart.MultipartFile;

public class AnalysisMultipartFileUtil {
	
	/**
	 * 获取文件后缀名
	 * @param multipartFile
	 * @return
	 */
	public static String getExe(MultipartFile multipartFile) {
		String[] strArray = multipartFile.getOriginalFilename().split("\\.");
		int suffixIndex = strArray.length - 1;
		// 文件后缀
		String exe = strArray[suffixIndex];
		return exe;
	}
	
	/**
	 * 获取新的文件名
	 * @param multipartFile
	 * @return
	 */
	public static String getNewFileName(MultipartFile multipartFile) {
		String uuid = UUID.randomUUID().toString().replace("-", "");
		String fileName = uuid + "." + getExe(multipartFile);
		return fileName;
	}

}
